import request from '@/utils/request'

// 查询仓库信息列表
export function listWarehouse(query) {
  return request({
    url: '/stock/warehouse/list',
    method: 'post',
    data: query
  })
}

// 查询仓库信息列表
export function listAvailableWarehouse(query) {
  query.status = '0';
  return request({
    url: '/stock/warehouse/list',
    method: 'post',
    data: query
  })
}

// 查询仓库信息详细
export function getWarehouse(id) {
  return request({
    url: '/stock/warehouse/' + id,
    method: 'get'
  })
}

export function upgrade() {
  return request({
    url: '/stock/warehouse/upgrade',
    method: 'get'
  })
}

/**
 * 获取仓库的库位信息
 * @param warehouseId 仓库id
 */
export function getWarelocations(warehouseId) {
  return request(
    {
      url: '/stock/warehouse/warelocations/' + warehouseId,
      method: 'get'
    }
  );
}

/**
 * 获取仓库的库位信息
 */
 export function listWarelocation(data) {
  return request(
    {
      url: '/stock/warehouse/warelocations/',
      method: 'post',
      data: data
    }
  );
}


// 新增仓库信息
export function addWarehouse(data) {
  return request({
    url: '/stock/warehouse/add',
    method: 'post',
    data: data
  })
}

// 配送信息
export function distributionEdit(data) {
  return request({
    url: '/stock/warehouse/distributionEdit',
    method: 'post',
    data: data
  })
}

// 修改仓库信息
export function updateWarehouse(data) {
  return request({
    url: '/stock/warehouse/update',
    method: 'post',
    data: data
  })
}

// 删除仓库信息
export function delWarehouse(id) {
  return request({
    url: '/stock/warehouse/delete/' + id,
    method: 'post'
  })
}

export function openWarehouse(id){
  return request({
    url: '/stock/warehouse/openWareHouse/' + id,
    method: 'post'
  })
}

export function closeWarehouse(id){
  return request({
    url: '/stock/warehouse/closeWareHouse/' + id,
    method: 'post'
  })
}

export function saveWarelocation(data){
  return request({
    url: '/stock/warehouse/saveWarelocation',
    method: 'post',
    data: data
  })
}

export function disableWarelocation(id){
  return request({
    url: '/stock/warehouse/disableWarelocation/' + id,
    method: 'post'
  })
}

export function enableWarelocation(id){
  return request({
    url: '/stock/warehouse/enableWarelocation/' + id,
    method: 'post'
  })
}

export function removeWarelocation(id){
  return request({
    url: '/stock/warehouse/removeWarelocation/' + id,
    method: 'post'
  })
}